// 获取assets静态资源
export const getAssetsFile = (url) => {
  return new URL(`../assets/img/${url}`, import.meta.url).href;
};
const startStr = '{"code"';
export const getAvailableUnits = (allStr, lastIndex, done) => {
  let cursor = lastIndex;
  let units = [];
  let _true = true;
  while (_true) {
    let firstIndex = allStr.indexOf(startStr, cursor);
    let secondIndex = allStr.indexOf(startStr, cursor + 1);
    if (done) {
      let unit = allStr.substring(firstIndex);
      units.push(unit);
      cursor = allStr.lastIndex - 1;
      // 退出
      break;
    } else {
      // 退出
      if (secondIndex == -1) break;
      let unit = allStr.substring(firstIndex, secondIndex);
      units.push(unit);
      cursor = secondIndex;
    }
  }
  return { units, cursor };
};
